//
//  HomeHeadView.m
//  beautyLamp
//
//  Created by Tam Kwok To Michael on 2017/9/15.
//  Copyright © 2017年 Tam Kwok To Michael. All rights reserved.
//

#import "HomeHeadView.h"

@interface HomeHeadView ()

@property (weak, nonatomic) IBOutlet UIButton *home;
@property (weak, nonatomic) IBOutlet UIButton *order;
@property (weak, nonatomic) IBOutlet UIButton *mine;

@end
@implementation HomeHeadView

+ (instancetype)homeHeadView {
    HomeHeadView *head = [[[NSBundle mainBundle] loadNibNamed:@"HomeHeadView" owner:nil options:nil] lastObject];
    return head;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupUI];
}

- (void)setupUI {
    self.home.selected = YES;
}

- (void)changeSomeState:(NSInteger)indxe {
    self.order.selected = NO;
    self.mine.selected = NO;
    self.home.selected = NO;
    if (indxe == 0) {
        self.home.selected = YES;
    } else if (indxe == 1) {
        self.order.selected = YES;
    } else if (indxe == 2) {
        self.mine.selected = YES;
    }

}


- (IBAction)homeClick:(UIButton *)sender {
    if (sender.isSelected)
        return;
    self.order.selected = NO;
    self.mine.selected = NO;
    self.home.selected = YES;
    if (_delegate && [_delegate respondsToSelector:@selector(scrollerToIndex:)]) {
        [_delegate scrollerToIndex:0];
    }
}

- (IBAction)orderClick:(UIButton *)sender {
    if (sender.isSelected)
        return;
    self.order.selected = YES;
    self.mine.selected = NO;
    self.home.selected = NO;
    if (_delegate && [_delegate respondsToSelector:@selector(scrollerToIndex:)]) {
        [_delegate scrollerToIndex:1];
    }
}

- (IBAction)mineClick:(UIButton *)sender {
    if (sender.isSelected)
        return;
    self.order.selected = NO;
    self.mine.selected = YES;
    self.home.selected = NO;
    if (_delegate && [_delegate respondsToSelector:@selector(scrollerToIndex:)]) {
        [_delegate scrollerToIndex:2];
    }
}

//- (CGSize)intrinsicContentSize {
//    return UILayoutFittingExpandedSize;
//}

@end
